//-----------------------------------------------------------------------------
// File: skybox.h
//
// Desc: Encapsulation of skybox geometry and textures
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef _SKYBOX_H
#define _SKYBOX_H
#include "..\common\ShareDef.h"

class CSkybox
{
public:
            CSkybox();

	HRESULT OnLoadCubeMapTexutre();
	HRESULT OnCreateDevice(IDirect3DDevice9* pd3dDevice, WCHAR* strEffectFileName, int useCubeMap);
	HRESULT OnCreateDevice( LPDIRECT3DDEVICE9 pd3dDevice, WCHAR* strCubeMapFile, WCHAR* strEffectFileName );
	HRESULT OnCreateDevice(WCHAR* strEffectFileName );
	HRESULT OpenCubeFace(D3DCUBEMAP_FACES FaceType, LPDIRECT3DCUBETEXTURE9 CubeTex, char* dir);



    void    OnResetDevice( const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
    void    Render();
    void    OnLostDevice();
    void    OnDestroyDevice();

	void SetCubeMapData();

	void SetInvMVPMatrix(D3DXMATRIX MVP){D3DXMatrixInverse(&g_invMVP, NULL, &MVP);}

    IDirect3DCubeTexture9* GetEnvironmentMap()
    {
        return g_pCubeMapTexture;
    }
    void    SetEnvironmentMap( IDirect3DCubeTexture9* pCubeTexture )
    {
        g_pCubeMapTexture = pCubeTexture;
    }

protected:
    //LPDIRECT3DCUBETEXTURE9 m_pEnvironmentMap;
    ID3DXEffect*				m_pEffect;
    LPDIRECT3DVERTEXBUFFER9		m_pCubeVB;
    IDirect3DVertexDeclaration9*m_pVertexDecl;
    LPDIRECT3DDEVICE9			m_pd3dDevice;

	LPDIRECT3DCUBETEXTURE9		g_pCubeMapTexture;


public:	
	char						g_CubeMapFilePath[MAX_FIND_RESULT][MAX_PATH];
	WCHAR						g_CubeMapName[MAX_FIND_RESULT][MAX_NAME_LEN];
	int							g_nCubeMapData;
	int							g_nCubeMapChosen;
	unsigned int				g_CubeMapWidth;
	unsigned int				g_CubeMapHeight;
	const WCHAR*				g_strEffectFileName;
	D3DXMATRIX					g_invMVP;
};

#endif //_SKYBOX_H_
